package org.ns.summer.example;

import com.zaxxer.hikari.HikariDataSource;
import org.ns.summer.beans.anns.Bean;
import org.ns.summer.beans.anns.Component;

import javax.sql.DataSource;

@Component
public class DataSourceConfig {
    public DataSourceConfig() {
        System.out.println("DataSourceConfig");
    }
    @Bean
    DataSource userdb() {
        HikariDataSource dataSource = new HikariDataSource();
        dataSource.setDriverClassName("com.mysql.jdbc.Driver");
        dataSource.setUsername("root");
        dataSource.setPassword("123456");
        dataSource.setJdbcUrl("jdbc:mysql://127.0.0.1:3306/test");
        dataSource.setMaximumPoolSize(5);
        dataSource.setMinimumIdle(2);
        System.out.println("数据源输出：");
        return dataSource;
    }
}
